package com.ruoyi.common.enums.business;


import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum TaskRewardRuleTypeEnum {

    FIXED_REWARD(1, "固定积分规则"),

    INVITATION_REWARD(2, "拉新规则"),

    QUALITY_REWARD(3, "品质积分"),

    OUT_CHAT_GROUP_REWARD(4, "外群规则"),

    IN_CHAT_GROUP_REWARD(5, "内群规则"),

    MATERIAL_TYPE_REWARD(6, "素材种类奖励规则"),

    XHS_TYPE_REWARD(7, "小红书奖励规则"),

    ;

    private final Integer status;

    private final String desc;


    private static final Map<Integer, TaskRewardRuleTypeEnum> ENUM_MAP;

    static {
        TaskRewardRuleTypeEnum[] values = values();
        Map<Integer, TaskRewardRuleTypeEnum> enToCn = new HashMap<>(values.length);
        for (TaskRewardRuleTypeEnum value : values) {
            enToCn.put(value.getStatus(), value);
        }
        ENUM_MAP = Collections.unmodifiableMap(enToCn);
    }

    /**
     * 根据类型查找枚举
     */
    public static TaskRewardRuleTypeEnum getEnumByType(Integer status) {
        TaskRewardRuleTypeEnum taskRewardRuleTypeEnum = ENUM_MAP.get(status);
        if (ObjectUtil.isEmpty(taskRewardRuleTypeEnum)) {
            throw new RuntimeException("类型有误");
        }
        return taskRewardRuleTypeEnum;
    }


}
